package com.zys.exercise;

import java.io.IOException;
import java.net.*;
import java.util.Scanner;

public class send {
    public static void main(String[] args) throws IOException {
        DatagramSocket ds = new DatagramSocket();
        InetAddress address = InetAddress.getByName("192.168.249.169");
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        while (true){
            System.out.println("请输入要传输的数据，以886结尾");
            String s = sc.next();
            sb.append(s);
            if(s.equals("886")){
                break;
            }
        }
        String s = sb.toString();
        byte[]bytes = s.getBytes();
        int iport = 10086;

        DatagramPacket dp = new DatagramPacket(bytes,bytes.length,address,iport);
        ds.send(dp);
        ds.close();

    }
}
